package com.mall.server.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mall.commons.utils.PageUtils;
import com.mall.dubbo.api.SmsFlashPromotionProductRelationApi;
import com.tanhua.model.domain.SmsFlashPromotionProductRelation;
import com.tanhua.model.vo.PageVo;
import org.apache.dubbo.config.annotation.DubboReference;

import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FlashProductRelationService {

    @DubboReference
    private SmsFlashPromotionProductRelationApi smsFlashPromotionProductRelationApi;


    /**
     * 分页查询不同场次关联及商品信息
     * @param flashPromotionId
     * @param flashPromotionSessionId
     * @param page
     * @return
     */
    public PageVo list(Integer flashPromotionId, Integer flashPromotionSessionId, Page<SmsFlashPromotionProductRelation> page) {
        Page result =smsFlashPromotionProductRelationApi.list(flashPromotionId,flashPromotionSessionId,page);
        return PageUtils.getPageVo(result);
    }

    /**
     * 修改关联信息
     * @param smsFlashPromotionProductRelation
     * @param smsFlashPromotionProductRelation
     * @return
     */
    public void updateFlashProductRelation(SmsFlashPromotionProductRelation smsFlashPromotionProductRelation) {
        smsFlashPromotionProductRelationApi.updateFlashProductRelation(smsFlashPromotionProductRelation);
    }

    /**
     * 删除关联
     * @param id
     */
    public void deleteFlashProductRelation(Long id) {
        smsFlashPromotionProductRelationApi.deleteFlashProductRelation(id);
    }


    /**
     * 批量选择商品添加关联
     * @param relationList
     * @return
     */
    public void createFlashProductRelation( List<SmsFlashPromotionProductRelation> relationList) {
        smsFlashPromotionProductRelationApi.createFlashProductRelation(relationList);
    }
}
